<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
</head>
<body>
</body>
<script>
    const url = 'https://ss3.bdstatic.com/70cFv8Sh_Q1YnxGkpoWK1HF6hhy/it/u=3791918726,2864900975&fm=26&gp=0.jpg'
    function loadImg(src) {
      return new Promise((resolve, reject) => {
        const img =document.createElement('img');
        img.onload = () => {
          resolve(img);
        }
        img.onerror = () => {
          const err = new Error(`图片加载失败${src}`)
          reject(err);
        }
        img.src = src;
      })
    }

    loadImg(url).then(value => {
      console.log(value.width);
      return value
    }).then(value => {
      console.log(value.height);
    }).catch(reason => {
      console.error(reason)
    });
</script>
</html>
